//===================================================================================================

// 版本号
const P3DTOOLKIT_VERSION = "5.0.0.5018";

//===================================================================================================

// 长度单位类型
const P3D_LENUNITTYPE_UNKOWN		= 0;	    // 未知类型
const P3D_LENUNITTYPE_MM			= 1;	    // 毫米
const P3D_LENUNITTYPE_CM			= 2;	    // 厘米
const P3D_LENUNITTYPE_M			    = 3;	    // 米
const P3D_LENUNITTYPE_MICRON		= 4;	    // 微米
const P3D_LENUNITTYPE_FT			= 5;	    // 英尺
const P3D_LENUNITTYPE_IN			= 6;	    // 英寸
const P3D_LENUNITTYPE_MIL			= 7;	    // 千分之一英寸
const P3D_LENUNITTYPE_ANGSTROM	    = 8;	    // 埃
const P3D_LENUNITTYPE_NANOMETER 	= 9;	    // 纳米

// 质量单位类型
const P3D_MASSUNITTYPE_UNKOWN		= 0;	    // 未知类型
const P3D_MASSUNITTYPE_KG			= 1;	    // 千克
const P3D_MASSUNITTYPE_G			= 2;	    // 克
const P3D_MASSUNITTYPE_MG			= 3;	    // 毫克
const P3D_MASSUNITTYPE_LBM		    = 4;	    // 磅
const P3D_MASSUNITTYPE_OUNCE_M	    = 5;	    // 盎司
const P3D_MASSUNITTYPE_SLUG		    = 6;	    // 斯勒格
const P3D_MASSUNITTYPE_TON_M		= 7;	    // 短吨
const P3D_MASSUNITTYPE_TONNE		= 8;	    // 吨

const P3D_HOME_TYPE_ALL = 0;                    // 复位数据类型
const P3D_HOME_TYPE_POSITION = 1;
const P3D_HOME_TYPE_COLOR = 2;
const P3D_HOME_TYPE_TRANS = 3;
const P3D_HOME_TYPE_VISIBLE = 4;
const P3D_HOME_TYPE_ANNOT = 5;
const P3D_HOME_TYPE_CAMERA = 6;

const P3D_MEASURE_NONE = 0;                     // 空测量，退出测量状态时使用
const P3D_MEASURE_OBJECT = 1;                   // 物件测量起始
const P3D_MEASURE_OBJECT_AUTO = 2;
const P3D_MEASURE_OBJECT_VOLUME = 3;
const P3D_MEASURE_OBJECT_SURFACE_AREA = 4;
const P3D_MEASURE_OBJECT_MASS = 5;
const P3D_MEASURE_OBJECT_MASS_CENTER = 6;
const P3D_MEASURE_OBJECT_BOUNDING_BOX = 7;
const P3D_MEASURE_CURVE = 10;                   // 曲线测量起始
const P3D_MEASURE_CURVE_AUTO = 11;
const P3D_MEASURE_CURVE_LINE = 12;
const P3D_MEASURE_CURVE_ARC = 13;
const P3D_MEASURE_ANGLE = 20;                   // 角度测量起始
const P3D_MEASURE_ANGLE_AUTO = 21;
const P3D_MEASURE_ANGLE_TWO_LINES = 22;
const P3D_MEASURE_ANGLE_TWO_PALNES = 23;
const P3D_MEASURE_ANGLE_LINE_PALNE = 24;
const P3D_MEASURE_DISTANCE = 30;                // 距离测量起始
const P3D_MEASURE_DISTANCE_AUTO = 31;
const P3D_MEASURE_DISTANCE_TWO_POINTS = 32;
const P3D_MEASURE_DISTANCE_POINT_LINE = 33;
const P3D_MEASURE_DISTANCE_POINT_PLANE = 34;
const P3D_MEASURE_DISTANCE_TWO_LINES = 35;
const P3D_MEASURE_DISTANCE_LINE_PLANE = 36;
const P3D_MEASURE_DISTANCE_TWO_PLANES = 37;
const P3D_MEASURE_DISTANCE_END = 40;

const P3D_CAPTURE_NONE = 0;
const P3D_CAPTURE_OBJECT = 1;
const P3D_CAPTURE_SURFACE = 2;
const P3D_CAPTURE_GEOM_SURFACE = 3;
const P3D_CAPTURE_GEOM_CURVE = 4;
const P3D_CAPTURE_GEOM_POINT = 5;
const P3D_CAPTURE_FREE_POINT = 6;

const P3D_BASE_OPT_MODE_DEFAULT = 0;
const P3D_BASE_OPT_MODE_MOVE = 1;
const P3D_BASE_OPT_MODE_ROTATE = 2;

const P3D_AT_UNKNOWN = 0;
const P3D_AT_DIMENSION = 1;
const P3D_AT_NOTE = 2;
const P3D_AT_DATUM = 3;
const P3D_AT_GTOL = 4;
const P3D_AT_SURFFINISH = 5;
const P3D_AT_TECHREQU = 6;

const P3D_RUNTIME_MODE_NORMAL = -1;
const P3D_RUNTIME_MODE_ANNOTATION = 0;
const P3D_RUNTIME_MODE_MEASURE = 1;
const P3D_RUNTIME_MODE_SECTION = 2;
const P3D_RUNTIME_MODE_PMI = 3;

const P3D_ELEMENT_TYPE_NONE = 0;
const P3D_ELEMENT_TYPE_PART = 1;
const P3D_ELEMENT_TYPE_SURFACE = 2;
const P3D_ELEMENT_TYPE_CURVE = 3;
const P3D_ELEMENT_TYPE_POINT = 4;
const P3D_ELEMENT_TYPE_OPT_COORD = 10;
const P3D_ELEMENT_TYPE_OPT_PLANE = 11;
const P3D_ELEMENT_TYPE_PMI_ITEM = 20;

const P3D_OBJ_MOVE_TYPE_WINDOW = 0;
const P3D_OBJ_MOVE_TYPE_WORLD_PARMS = 1;
const P3D_OBJ_MOVE_TYPE_WORLD_NAVIGATOR = 2;

const P3D_EXPLODE_MODE_X = 0;
const P3D_EXPLODE_MODE_Y = 1;
const P3D_EXPLODE_MODE_Z = 2;
const P3D_EXPLODE_MODE_FREE = 3;

const P3D_RENDER_MODE_SHADER = 0;
const P3D_RENDER_MODE_FRAME = 1;
const P3D_RENDER_MODE_PROJECTION = 2;
const P3D_RENDER_MODE_HALF_TRANSPARENT = 3;
const P3D_RENDER_MODE_WIRE_FRAME = 4;
const P3D_RENDER_MODE_INK = 5;
const P3D_RENDER_MODE_X_RAY = 6;
const P3D_RENDER_MODE_PBR = 7;

//===================================================================================================

function P3D_SETTINGS() {
    // 设置背景类型，1表示使用背景图，2表示使用背景色
    this.bgType = 1;
    // 设置默认背景颜色
    this.defaultBgColor = new P3D_RGBA();
    // 设置P3DToolKit内置背景图片，Resource目录下，默认blue.jpg
    this.defaultBgImage = "";
    // 设置背景图片URL，如果不为空则使用此背景图片
    this.defaultBgUrl = "";
    // 设置场景灯光，默认开启
    this.defaultLightOn = true;
    // 设置几何数据开关，默认开启
    this.defaultGeomtryOn = true;
    // 设置基础操作类型
    this.defaultBaseOptMode = 0;
    // 设置canvas是否透明，默认不透明 （true为透明效果， false为不透明效果）
    this.defaultCanvasTransparency = false;
    // 设置场景导航器开关，默认打开
    this.defaultNavigatorEnable = true;
}

// 场景系统单位
function P3D_FILESCENE_UNIT() {  
    this._nLengthUnit = P3D_LENUNITTYPE_UNKOWN;         // 长度单位,参看P3D_LENUNITTYPE_UNKOWN类型
    this._nMassUnit = P3D_MASSUNITTYPE_UNKOWN;          // 质量单位,参看P3D_MASSUNITTYPE_UNKOWN类型
}

// 文件场景信息
function P3D_FILESCENEINFO() {
    this._uModelNum = 0;				                // 模型数量
	this._uObjectNum = 0;				                // 模型实例数量
    this._uObjTreeNodeNum = 0;			                // 模型树节点数量
    this._uModelTriNum = 0;				                // 模型三角片数量
    this._uObjectTriNum = 0;			                // 模型实例三角片数量
}

// 模型树
function P3D_MODELTREENODE() {
    this._uTreeNodeID = -1;
    this._uObjectID = -1;
    this._strName = "";
    this._uAnnoID = -1;		                            // 标注（PMI）ID, Uint32
    this._bVisible = true;
    this._arrNodeParameters = new Array();              // 类型P3D_NODEPARAMETER
    this._arrSubNode = new Array();                     // 类型P3D_MODELTREENODE
}

// 模型树节点参数
function P3D_NODEPARAMETER() {
    this._strName = "";                                 // 参数名
    this._strValue = "";                                // 参数值
}

// 材质信息
function P3D_MATERIALINFO() {
    this._strName = "";
    this._uMaterialID = 0;
}

// 包围盒
function P3D_BOX() {
    this._min = new P3D_BASEFLOAT3();                   // 包围盒最小点
    this._max = new P3D_BASEFLOAT3();                   // 包围盒最大点
}

// 三维向量(单精)
function P3D_BASEFLOAT3() {
	this.x = 0.0;   
	this.y = 0.0;   
	this.z = 0.0;   

    this.set = function(x, y, z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    this.Clone = function () {
        var newData = new P3D_BASEFLOAT3();

        newData.x  = this.x;  
        newData.y  = this.y;   
        newData.z  = this.z;  
        return newData;
    }

    this.Copy = function (data) {
        this.x  = data.x; 
        this.y  = data.y; 
        this.z  = data.z; 
    }	
}

// 矩阵(单精)
function P3D_BASEMATRIX(){
	this._11 = 1.0;				// Float32
	this._12 = 0.0;				// Float32
	this._13 = 0.0;				// Float32
	this._14 = 0.0;				// Float32

	this._21 = 0.0;				// Float32
	this._22 = 1.0;				// Float32
	this._23 = 0.0;				// Float32
	this._24 = 0.0;				// Float32

	this._31 = 0.0;				// Float32
	this._32 = 0.0;				// Float32
	this._33 = 1.0;				// Float32
	this._34 = 0.0;				// Float32

	this._41 = 0.0;				// Float32	
	this._42 = 0.0;				// Float32
	this._43 = 0.0;				// Float32
	this._44 = 1.0;				// Float32

	this.Clear = function () {
		this._11 = 1.0;				
		this._12 = 0.0;				
		this._13 = 0.0;				
		this._14 = 0.0;				
	
		this._21 = 0.0;				
		this._22 = 1.0;				
		this._23 = 0.0;				
		this._24 = 0.0;				
	
		this._31 = 0.0;				
		this._32 = 0.0;				
		this._33 = 1.0;				
		this._34 = 0.0;				
	
		this._41 = 0.0;					
		this._42 = 0.0;				
		this._43 = 0.0;				
		this._44 = 1.0;				
	}
	this.Clone = function () {
		var newData = new P3D_BASEMATRIX();
		newData._11 = this._11;
		newData._12 = this._12;
		newData._13 = this._13;
		newData._14 = this._14;

		newData._21 = this._21;
		newData._22 = this._22;
		newData._23 = this._23;
		newData._24 = this._24;

		newData._31 = this._31;
		newData._32 = this._32;
		newData._33 = this._33;
		newData._34 = this._34;

		newData._41 = this._41;
		newData._42 = this._42;
		newData._43 = this._43;
		newData._44 = this._44;

		return newData;
	}
	this.Copy = function (data) {
		this._11 = data._11;
		this._12 = data._12;
		this._13 = data._13;
		this._14 = data._14;

		this._21 = data._21;
		this._22 = data._22;
		this._23 = data._23;
		this._24 = data._24;

		this._31 = data._31;
		this._32 = data._32;
		this._33 = data._33;
		this._34 = data._34;

		this._41 = data._41;
		this._42 = data._42;
		this._43 = data._43;
		this._44 = data._44;
	}
}

function P3D_RGBA() {
    this._alpha = 255;                                     // 透明度，取值范围0~255
	this._red = 0;                                         // 红，取值范围0~255
	this._green = 0;                                       // 绿，取值范围0~255
	this._blue = 0;                                        // 蓝，取值范围0~255

    this.Clone = function () {
        var newData = new P3D_RGBA();

        newData._alpha  = this._alpha;  
        newData._red  = this._red;   
        newData._green  = this._green;  
        newData._blue  = this._blue;  
        return newData;
    }

    this.Copy = function (data) {
        this._alpha  = data._alpha; 
        this._red  = data._red; 
        this._green  = data._green; 
        this._blue  = data._blue; 
    }	
}

// 摄像机
function P3D_CAMERA() {  
    this._vEyePos = new P3D_BASEFLOAT3();			        // 摄像机位置
    this._vFocus = new P3D_BASEFLOAT3();			        // 摄像机焦点
    this._vUp = new P3D_BASEFLOAT3();			            // 摄像机上方向
    this._fFOVY = 0;				                        // Y方向的视角
    this._fAspect = 0;				                        // 宽高比
    this._fZNear = 0;				                        // 近平面, Float32
    this._fZFar = 0;				                        // 远平面, Float32  
    this._fInterocularDistance = 0;				            // 目间距

    this.Clone = function () {
        var newData = new P3D_CAMERA();
        
        newData._vEyePos.Copy(this._vEyePos); 
        newData._vFocus.Copy(this._vFocus);  
        newData._vUp.Copy(this._vUp);  

        newData._fFOVY  = this._fFOVY;   
        newData._fAspect  = this._fAspect;   
        newData._fZNear  = this._fZNear;   
        newData._fZFar  = this._fZFar;  
        newData._fInterocularDistance  = this._fInterocularDistance;   

        return newData;
    }

    this.Copy = function (data) {
        this._vEyePos.Copy(data._vEyePos); 
        this._vFocus.Copy(data._vFocus); 
        this._vUp.Copy(data._vUp); 

        this._fFOVY  = data._fFOVY; 
        this._fAspect  = data._fAspect; 
        this._fZNear  = data._fZNear; 
        this._fZFar  = data._fZFar; 
        this._fInterocularDistance  = data._fInterocularDistance; 
    }	
} 

// 场景事件
function P3D_SCENEANIMNODE() {
    this._uTimeNodeID = -1;	                                // 节点对应的时间节点ID, Uint32
	this._strName = '';	                                    // 名称
	this._strNote = '';                                     // 注释
	this._uStart = 0;				                        // 起始帧, Uint32
    this._uEnd = 0;					                        // 帧长度, Uint32
    this._arrSubNode = new Array();			                // 子节点，存储P3D_SCENEANIMNODE对象
}

// 拾取三维物体
function P3D_PICK_ELEMENT() {
    this._uPickType = P3D_ELEMENT_TYPE_NONE;                // 拾取的元素类型，见P3D_PICK_TYPE枚举值
    this._arrPickElements = new Array();                    // 拾取元素的ID数组，单选时只有一个元素
}

// 注释信息
function P3D_COMMENTINFO() {
	this._uCommentID  = -1;					                // 注释ID
	this._szUserName = '';		                            // 用户名
    this._szUserID = '';		                            // 用户ID
	this._szDateTime = '';		                            // 注释日期时间,格式:20170810092832，前8位表示日期，后期6位表示时间
	this._stuCamera = new P3D_CAMERA;				        // 注释摄像机数据

	this._szName = '';			                            // 注释名字
	this._szText = '';			                            // 注释内容

	this._planeOrigin = new P3D_BASEFLOAT3();		        // 三维注释平面原点坐标
	this._planeX = new P3D_BASEFLOAT3();			        // 三维注释平面坐标系x轴方向
	this._planeY = new P3D_BASEFLOAT3();			        // 三维注释平面坐标系y轴方向
	this. _planeZ = new P3D_BASEFLOAT3();			        // 三维注释平面坐标系z轴方向

	this._bVisible = true;							        // 是否可见
	this._bIsFront = false;							        // 是否前端显示
	this._bIsScreenAnnot = true;					        // 是否为屏幕标注（若为屏幕标注,则"是否前端显示"无意义）

	this._attachPos = new P3D_BASEFLOAT3();			        // 放置位置
    this._arrLeaderPos = new Array();			            // 引线位置，存储P3D_BASEFLOAT3对象
    this._arrLeaderObjId = new Array();			            // 引线所指物件id

    this._uStartFrameID = 0;
    this._uEndFrameID = 0;
}

// 剖切视图信息
function P3D_SECTION_PLANE_INFO() {
    this.vOrigin = new P3D_BASEFLOAT3();		            // 三维剖切平面原点坐标
    this.vAxisX = new P3D_BASEFLOAT3();		                // 三维剖切平面坐标系X轴方向
    this.vAxisY = new P3D_BASEFLOAT3();		                // 三维剖切平面坐标系Y轴方向
    this.vAxisZ = new P3D_BASEFLOAT3();		                // 三维剖切平面坐标系Z轴方向
    this.bVisible = false;		                            // 三维剖切平面是否可见，1表示可见，0表示不可见
    this.bRevert = false;		                            // 三维剖切平面是否反转，1表示反转，0表示不反转
}

// 模型实例的属性信息
function ObjectAttrInfo() {
    this.mass = 0;                                      // 质量
    this.volume = 0;                                    // 体积
    this.surfaceArea = 0;                               // 表面积
    this.massCenterPos = new P3D_BASEFLOAT3(0, 0, 0);   // 质心位置
}

//===================================================================================================
// 三维标记相关的定义

// 三维标记类型
const P3DMARK_NONE				= 0;			// 无
const P3DMARK_TEXT				= 1;			// 屏幕文字(无引线)
const P3DMARK_IMAGE				= 2;			// 屏幕图像(无引线)
const P3DMARK_NOTE				= 3;			// 批注(文字有引线)
const P3DMARK_IMAGENOTE			= 4;			// 图像批注(有引线)
const P3DMARK_POINT				= 5;			// 屏幕点
const P3DMARK_LINE				= 6;			// 屏幕直线
const P3DMARK_FOLDLINE			= 7;			// 屏幕折线
const P3DMARK_PENCIL			= 8;			// 屏幕自由线
const P3DMARK_RECTANGLE		    = 9;			// 屏幕矩形
const P3DMARK_ELLIPSE			= 10;			// 屏幕椭圆
const P3DMARK_POLYGON			= 11;			// 屏幕多边形	
const P3DMARK_MEASURE			= 12;			// 屏幕测量

const P3DMARK_WORLD_POINT		= 50;           // 点（世界坐标）
const P3DMARK_WORLD_PENCIL		= 51;			// 自由画线(世界坐标)

const P3DMARK_LOCAL_POINT		= 100;			// 点(模型局部坐标）
const P3DMARK_LOCAL_LINE		= 101;			// 线(模型局部坐标)
const P3DMARK_LOCAL_FOLDLINE	= 102;			// 折线(模型局部坐标)
const P3DMARK_LOCAL_RECTANGLE	= 103;			// 矩形(模型局部坐标)
const P3DMARK_LOCAL_ELLIPSE		= 104;			// 椭圆(模型局部坐标)
const P3DMARK_LOCAL_POLYGON		= 105;			// 多边形(模型点局部坐标)   

// 三维坐标投影到二维坐标信息
function P3DMARK_POINTSPACE() {	
    this.pos = new P3D_BASEFLOAT3(0, 0, 0);     // 空间点的x, y, z坐标
    this.flag = 1;                              // 点标志位 1: local, 2: world，3: Window 4：模型实例中心点坐标，5：模型实例原点
    this.objID = -1;				            // 模型实例ID

    this.Clone = function () {
        var newData = new P3DMARK_POINTSPACE();

        newData.pos.Copy(this.pos);  
        newData.flag  = this.flag;   
        newData.objID  = this.objID;   

        return newData;
    }

    this.Copy = function (data) {
        this.pos.Copy(data.pos); 
        this.flag  = data.flag; 
        this.objID  = data.objID; 
    }	
}

// 三维标记属性标志位
const P3DMARK_FLAG_NONE		    = 0x00;			// 无
const P3DMARK_FLAG_VISIBLE	    = 0x01;			// 可见标志位
const P3DMARK_FLAG_ENABLE		= 0x02;			// 是否Enable标志位
const P3DMARK_FLAG_FILLED		= 0x04;			// 是否填充标志位
const P3DMARK_FLAG_CLOSED		= 0x08;			// 是否封闭标志为，此标志位区分多边形和折线
const P3DMARK_FLAG_BORDER		= 0x10;			// 是否显示边框
const P3DMARK_FLAG_CLIP		    = 0x20;			// 是否按照边框裁剪
const P3DMARK_FLAG_CAMERA		= 0x40;			// 是否有照相机数据
const P3DMARK_FLAG_REPLY		= 0x80;			// 是否具有回复的含义

// 三维标记线条标样式
const P3DMARK_LINE_SOLID		    = 1;		// 实线 ————
const P3DMARK_LINE_DASH			    = 2;		// 虚线 ----
const P3DMARK_LINE_DOT			    = 3;		// 点线 .....
const P3DMARK_LINE_DASHDOT		    = 4;		// 点划线 _._._.
const P3DMARK_LINE_DASHDOTDOT		= 5;		// 点划线 _.._.._..

// 三维标记线条端点样式
const P3DMARK_LINEEP_NONE			= 0;		// 无样式
const P3DMARK_LINEEP_ARROW		    = 1;		// 箭头
const P3DMARK_LINEEP_ROUND		    = 2;		// 圆

// 三维标记线条属性
function P3DMARK_LINEATTR() {
	this.ubStyle = P3DMARK_LINE_SOLID;			// 线条样式
	this.ubWidth = 1;							// 线条宽度
	this.color = new P3D_RGBA();				// 线条颜色
	this.ubStartStyle = P3DMARK_LINEEP_NONE;	// 线条起始点样式
	this.ubEndStyle = P3DMARK_LINEEP_NONE;		// 线条终止点样式

    this.Clone = function () {
        var newData = new P3DMARK_LINEATTR();

        newData.ubStyle  = this.ubStyle;   
        newData.ubWidth  = this.ubWidth;   
        newData.color.Copy(this.color);  
        newData.ubStartStyle  = this.ubStartStyle;   
        newData.ubEndStyle  = this.ubEndStyle;   

        return newData;
    }

    this.Copy = function (data) {
        this.ubStyle  = data.ubStyle; 
        this.ubWidth  = data.ubWidth; 
        this.color.Copy(data.color); 
        this.ubStartStyle  = data.ubStartStyle; 
        this.ubEndStyle  = data.ubEndStyle; 
    }	
}

// 三维标记字体的大小
const P3DMARK_FONTSIZE_ZERO	    = 1;	// 初号:420
const P3DMARK_FONTSIZE_ZERO1	= 2;	// 小初:360
const P3DMARK_FONTSIZE_ONE	    = 3;	// 一号:315
const P3DMARK_FONTSIZE_ONE1	    = 4;	// 小一:280
const P3DMARK_FONTSIZE_TWO	    = 5;	// 二号:210
const P3DMARK_FONTSIZE_TWO2	    = 6;	// 小二:180
const P3DMARK_FONTSIZE_THREE	= 7;	// 三号:160
const P3DMARK_FONTSIZE_THREE2   = 8;	// 小三:150
const P3DMARK_FONTSIZE_FOUR 	= 9;	// 四号:140
const P3DMARK_FONTSIZE_FOUR2	= 10;	// 小四:120
const P3DMARK_FONTSIZE_FIVE	    = 11;   // 五号:105
const P3DMARK_FONTSIZE_FIVE2	= 12;   // 小五:90
const P3DMARK_FONTSIZE_SIX	    = 13;   // 六号:80
const P3DMARK_FONTSIZE_SIX2	    = 14;   // 小六:68
const P3DMARK_FONTSIZE_SEVEN	= 15;   // 七号:52
const P3DMARK_FONTSIZE_EIGHT	= 16	// 八号:40

// 三维标记文字加粗，斜体等样式
const P3DMARK_TEXTFLAG_NONE	    = 0x00;	// 默认
const P3DMARK_TEXTFLAG_BOLD	    = 0x01;	// 加粗
const P3DMARK_TEXTFLAG_ITALIC   = 0x02; // 斜体

// 三维标记字体属性
function P3DMARK_TEXTATTRIBUTE() {
	this.szFontName = "";	                        // 字体名称
	this.baseLinePos = new P3DMARK_POINTSPACE();	// 字体基准线点
	this.eFontSize = P3DMARK_FONTSIZE_FOUR2;
	this.textFlag = P3DMARK_TEXTFLAG_NONE;

    this.Clone = function () {
        var newData = new P3DMARK_TEXTATTRIBUTE();

        newData.szFontName  = this.szFontName;   
        newData.baseLinePos.Copy(this.baseLinePos);  
        newData.eFontSize  = this.eFontSize;   
        newData.textFlag  = this.textFlag;   

        return newData;
    }

    this.Copy = function (data) {
        this.szFontName  = data.szFontName; 
        this.baseLinePos.Copy(data.baseLinePos); 
        this.eFontSize  = data.eFontSize; 
        this.textFlag  = data.textFlag; 
    }	
}

// 边框的修饰形状
const P3DMARK_BORDERSHAPE_NULL = 0;					// 无
const P3DMARK_BORDERSHAPE_LINE = 1;					// 直线
const P3DMARK_BORDERSHAPEE_RECTANGLE = 2;			// 矩形
const P3DMARK_BORDERSHAPEE_CIRCLE = 3;				// 圆

// 三维标记边框属性
function P3DMARK_BORDERATTR() {
	this.lineAttribute = new P3DMARK_LINEATTR();    // 边框线条样式
	this.bRadiusLeftTop = 0;					    // 圆角半径左上角,默认0
	this.bRadiusRightTop = 0;					    // 圆角半径右上角,默认0
	this.bRadiusRightBottom = 0;				    // 圆角半径右下角,默认0
	this.bRadiusLeftBottom = 0;				        // 圆角半径左下角,默认0
	this.bPadding = 0;						        // 边框与对象之间,距离
    this.shape = P3DMARK_BORDERSHAPEE_RECTANGLE;	// 参考SVTDBORDERSHAPETYLE枚举值

    this.Clone = function () {
        var newData = new P3DMARK_BORDERATTR();

        newData.lineAttribute.Copy(this.lineAttribute);  
        newData.bRadiusLeftTop  = this.bRadiusLeftTop;   
        newData.bRadiusRightTop  = this.bRadiusRightTop;   
        newData.bRadiusRightBottom  = this.bRadiusRightBottom;   
        newData.bRadiusLeftBottom  = this.bRadiusLeftBottom;  
        newData.bPadding  = this.bPadding;   
        newData.shape  = this.shape;   

        return newData;
    }

    this.Copy = function (data) {
        this.lineAttribute.Copy(data.lineAttribute); 
        this.bRadiusLeftTop  = data.bRadiusLeftTop; 
        this.bRadiusRightTop  = data.bRadiusRightTop; 
        this.bRadiusRightBottom  = data.bRadiusRightBottom; 
        this.bRadiusLeftBottom  = data.bRadiusLeftBottom; 
        this.bPadding  = data.bPadding; 
        this.shape  = data.shape;   
    }	
}

// 三维标记图像格式
const P3DMARK_IMAGE_NONE		= 1;		// 图像格式无
const P3DMARK_IMAGE_BMP		    = 2;		// 图像格式为BMP
const P3DMARK_IMAGE_PNG		    = 3;		// 图像格式为PNG
const P3DMARK_IMAGE_JPEG		= 4;		// 图像格式为JPEG
const P3DMARK_IMAGE_BASIU		= 5;		// 图像格式为basiu

// 三维标记点的样式
const P3DMARK_POINT_NONE		= 1;	    // 无样式
const P3DMARK_POINT_ROUND		= 2;	    // 显示为实心圆
const P3DMARK_POINT_CROSS		= 3;	    // 显示为十字
const P3DMARK_POINTE_ROUNDCROSS	= 4;		// 显示为十字+圆

// 三维标记基础项
function P3D_BASEMARK() {
    this.uAttriFlags = P3DMARK_FLAG_VISIBLE | P3DMARK_FLAG_ENABLE | P3DMARK_FLAG_BORDER;			// 属性标志位
    this.uID = -1;					                                        // 自身ID
	this.uParentID = -1;			                                        // 父亲ID
	this.eLineAttri = new P3DMARK_LINEATTR();		                        // 线条属性
	this.eBorderAttri = new P3DMARK_BORDERATTR(); 	                        // 边框属性
	this.fillcolor = new P3D_RGBA();					                    // 填充颜色
	this.cameraData = null;				                                    // 相机数据，取决于标志位_uAttriFlags里的const P3DMARK属性
	this.nStartFrame = -1;					                                // 起始帧
	this.nEndFrame = -1;						                            // 终止帧

    this.strName;                                                           // 标记名称
    this.strUserName;                                                       // 用户名
    this.strUserID;                                                         // 用户唯一标识

    this.uCreationDate;                                                     // 创建的时间，取值为相对于1970年1月1日0时的秒数
    this.uModDate;                                                          // 上一次修改的时间，取值为相对于1970年1月1日0时的秒数

    this.Clone = function () {
        var newData = new P3D_BASEMARK();
        
        newData.uID  = this.uID;  
        newData.uParentID  = this.uParentID;  
        newData.uAttriFlags  = this.uAttriFlags;  

        newData.eLineAttri.Copy(this.eLineAttri); 
        newData.eBorderAttri.Copy(this.eBorderAttri);  
        newData.fillcolor.Copy(this.fillcolor);  

        if (this.cameraData = null) {
            newData.cameraData = new P3D_CAMERA();
            newData.cameraData.Copy(this.fillcolor);
        }

        newData.nStartFrame  = this.nStartFrame;   
        newData.nEndFrame  = this.nEndFrame;   

        newData.strName  = this.strName; 
        newData.strUserName  = this.strUserName; 
        newData.strUserID  = this.strUserID; 
        newData.uCreationDate  = this.uCreationDate; 
        newData.uModDate  = this.uModDate; 

        return newData;
    }

    this.Copy = function (data) {
        this.uID  = data.uID; 
        this.uParentID  = data.uParentID;
        this.uAttriFlags  = data.uAttriFlags;

        this.eLineAttri.Copy(data.eLineAttri); 
        this.eBorderAttri.Copy(data.eBorderAttri); 
        this.fillcolor.Copy(data.fillcolor); 
    
        if (data.cameraData = null) {
            this.cameraData = new P3D_CAMERA();
            this.cameraData.Copy(data.fillcolor);
        }

        this.nStartFrame  = data.nStartFrame; 
        this.nEndFrame  = data.nEndFrame; 

        this.strName  = data.strName; 
        this.strUserName  = data.strUserName; 
        this.strUserID  = data.strUserID; 
        this.uCreationDate  = data.uCreationDate; 
        this.uModDate  = data.uModDate; 
    }	
}

// 文字标记项
function P3D_TEXTMARK() {
	this.baseInfo = new P3D_BASEMARK();				// 基础信息
	this.fontAttri = new P3DMARK_TEXTATTRIBUTE();	// 字体属性
	this.color = new P3D_RGBA();;					// 文字颜色
	this.content = "";		                        // 文字内容

    this.Clone = function () {
        var newData = new P3D_TEXTMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        newData.fontAttri.Copy(this.fontAttri);  
        newData.color.Copy(this.color);  
        newData.content  = this.content;   
        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 
        this.fontAttri.Copy(data.fontAttri); 
        this.color.Copy(data.color);   
        this.content  = data.content; 
    }	
}

// 图像标记项
function P3D_IMAGEMARK() {
	this.baseInfo = new P3D_BASEMARK();				// 基础信息
	this.imageType = P3DMARK_IMAGE_JPEG;			// 图像格式类型
	this.startPoint = new P3DMARK_POINTSPACE();		// 起始空间点
	this.endPoint = new P3DMARK_POINTSPACE();		// 终止空间点

    this.imageData = "";                            // 图像数据，base64编码，包含图像前缀
 
    this.Clone = function () {
        var newData = new P3D_IMAGEMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        newData.imageType  = this.imageType;  

        newData.startPoint.Copy(this.startPoint);  
        newData.endPoint.Copy(this.endPoint);  

        newData.imageData  = this.imageData;

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 
        this.imageType  = data.imageType; 

        this.startPoint.Copy(data.startPoint); 
        this.endPoint.Copy(data.endPoint);   

        this.imageData  = data.imageData; 
    }	
}

// 点标记项
function P3D_POINTMARK() {
	this.baseInfo = new P3D_BASEMARK();				// 基础信息
	this.pos = new P3DMARK_POINTSPACE();			// 空间坐标
	this.ePointStyle = P3DMARK_POINT_NONE;			// 点显示类型
	this.nLength = 5;						        // 圆半径或十字线半长度

    this.Clone = function () {
        var newData = new P3D_POINTMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        newData.pos.Copy(this.pos);  

        newData.ePointStyle  = this.ePointStyle;   
        newData.nLength  = this.nLength;   

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 
        this.pos.Copy(data.pos); 
   
        this.ePointStyle  = data.ePointStyle; 
        this.nLength  = data.nLength; 
    }	
}

// 直线标记项
function P3D_LINEMARK() {
	this.baseInfo = new P3D_BASEMARK();				    // 基础信息
	this.startPos  = new P3DMARK_POINTSPACE();			// 起始空间点
	this.endPos  = new P3DMARK_POINTSPACE();			// 起始空间点

    this.Clone = function () {
        var newData = new P3D_LINEMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        newData.startPos.Copy(this.startPos);  
        newData.endPos.Copy(this.endPos);  

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 
        this.startPos.Copy(data.startPos); 
        this.endPos.Copy(data.endPos); 
    }
}

// 折线标记项
function P3D_FOLDLINEMARK() {
	this.baseInfo = new P3D_BASEMARK();				// 基础信息
    this.posList = new Array();			            // 空间点列表，存储MarkPointSpace对象

    this.Clone = function () {
        var newData = new P3D_FOLDLINEMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        for (var i in this.posList){
            newData.posList[i] = this.posList[i];
        }

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 

        this.posList.splice(0, this.posList.length);
        for (var i in data.posList){
            this.posList[i] = data.posList[i];
        } 
    }
}

// 射线标记项
function P3D_RAYLINEMARK() {
	this.baseInfo = new P3D_BASEMARK();				// 基础信息
    this.startPos  = new P3DMARK_POINTSPACE();		// 起始空间点
    this.posList = new Array();			            // 终点点列表，存储MarkPointSpace对象
    this.arrObj = new Array();			            // 射线关联的多个模型实例ID，如果为0，使用终点引用的对象,存储MarkPointSpace对象

    this.Clone = function () {
        var newData = new P3D_RAYLINEMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        newData.startPos.Copy(this.startPos); 
        for (var i in this.posList){
            newData.posList[i] = this.posList[i];
        }

        for (var i in this.arrObj){
            newData.arrObj[i] = this.arrObj[i];
        }

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 
        this.startPos.Copy(data.startPos); 

        this.posList.splice(0, this.posList.length);
        for (var i in data.posList){
            this.posList[i] = data.posList[i];
        } 

        this.arrObj.splice(0, this.arrObj.length);
        for (var i in data.arrObj){
            this.arrObj[i] = data.arrObj[i];
        } 
    }
}

// 自由标记项
function P3D_PENCILMARK() {
	this.baseInfo = new P3D_BASEMARK();				// 基础信息
    this.posList = new Array();			            // 终点点列表

    this.Clone = function () {
        var newData = new P3D_PENCILMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        for (var i in this.posList){
            newData.posList[i] = this.posList[i];
        }

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo);        
        this.posList.splice(0, this.posList.length);
        for (var i in data.posList){
            this.posList[i] = data.posList[i];
        } 
    }
}

// 矩形标记项
function P3D_RECTANGLEMARK() {
	this.baseInfo = new P3D_BASEMARK();				// 基础信息
    this.ubRadiusLeftTop = 0;		                // 圆角半径左上角LeftTop, 默认0
    this.ubRadiusRightTop = 0;	                    // 圆角半径右上角RightTop, 默认0
    this.ubRadiusRightBottom = 0;	                // 圆角半径右下角RightBottom, 默认0
    this.ubRadiusLeftBottom = 0;	                // 圆角半径左下角LeftBottom, 默认0

    this.startPos  = new P3DMARK_POINTSPACE();		// 起始空间点
    this.endPos  = new P3DMARK_POINTSPACE();		// 终止空间点
    
    this.Clone = function () {
        var newData = new P3D_RECTANGLEMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        newData.startPos.Copy(this.startPos); 
        newData.endPos.Copy(this.endPos); 

        this.ubRadiusLeftTop  = data.ubRadiusLeftTop; 
        this.ubRadiusRightTop  = data.ubRadiusRightTop; 
        this.ubRadiusRightBottom  = data.ubRadiusRightBottom; 
        this.ubRadiusLeftBottom  = data.ubRadiusLeftBottom;        

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo);  
        this.startPos.Copy(data.startPos);
        this.endPos.Copy(data.endPos);    

        data.ubRadiusLeftTop  = this.ubRadiusLeftTop; 
        data.ubRadiusRightTop  = this.ubRadiusRightTop; 
        data.ubRadiusRightBottom  = this.ubRadiusRightBottom; 
        data.ubRadiusLeftBottom  = this.ubRadiusLeftBottom;          
    }
}

// 椭圆标记项
function P3D_ELLIPSEMARK() {
	this.baseInfo = new P3D_BASEMARK();				// 基础信息
    this.startPos  = new P3DMARK_POINTSPACE();			// 起始空间点
    this.endPos  = new P3DMARK_POINTSPACE();			// 终止空间点

    this.Clone = function () {
        var newData = new P3D_ELLIPSEMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        newData.startPos.Copy(this.startPos); 
        newData.endPos.Copy(this.endPos);    

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo);  
        this.startPos.Copy(data.startPos);
        this.endPos.Copy(data.endPos); 
    }
} 

// 多边形标记项
function P3D_POLYGONMARK() {
	this.baseInfo = new P3D_BASEMARK();				// 基础信息
    this.posList = new Array();			            // 空间点列表，存储MarkPointSpace对象

    this.Clone = function () {
        var newData = new P3D_POLYGONMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        for (var i in this.posList){
            newData.posList[i] = this.posList[i];
        }

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 

        this.posList.splice(0, this.posList.length);
        for (var i in data.posList){
            this.posList[i] = data.posList[i];
        } 
    }
}

// 批注文本放置类型
const P3DMARKNOTE_ATTACH_DOWN = 1;				// 下角
const P3DMARKNOTE_ATTACH_CENTER = 2;			// 中心
const P3DMARKNOTE_ATTACH_UP = 3;				// 上角

// 文字批注记项
function P3D_TEXTNOTEMARK()  {
	this.baseInfo = new P3D_BASEMARK();			// 基础信息
    this.text = new P3D_TEXTMARK();			    // 文字信息
    this.ray = new P3D_RAYLINEMARK();			// 射线信息
    this.attachType = P3DMARKNOTE_ATTACH_CENTER;	// 参考P3DMARKNOTE_ATTACH_

    this.Clone = function () {
        var newData = new P3D_TEXTNOTEMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        newData.text.Copy(this.text); 
        newData.ray.Copy(this.ray); 
        newData.attachType  = this.attachType; 

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 
        this.text.Copy(data.text); 
        this.ray.Copy(data.ray); 
        this.attachType  = data.attachType;
    }
}

// 图像批注记项
function P3D_IMAGENOTEMARK()  {
	this.baseInfo = new P3D_BASEMARK();			// 基础信息
    this.image = new P3D_IMAGEMARK();			// 图像信息
    this.ray = new P3D_RAYLINEMARK();			// 射线信息

    this.Clone = function () {
        var newData = new P3D_IMAGENOTEMARK();
        
        newData.baseInfo.Copy(this.baseInfo); 
        newData.image.Copy(this.image); 
        newData.ray.Copy(this.ray); 

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 
        this.image.Copy(data.image); 
        this.ray.Copy(data.ray); 
    }
}

// 测量的几何信息
function P3D_GEOMTEYINFO() {
    this.elementType = 0;
    this.objectIndex = -1;                     // todo, 文件存储应该objID
    this.geomSurfaceIndex = -1;
    this.geomCurveIndex = -1;
    this.geomPointIndex = -1;
    this.freePoint = new P3D_BASEFLOAT3(0, 0, 0);

    this.Clone = function () {
        var newData = new P3D_GEOMTEYINFO();
        
        newData.elementType  = this.elementType; 
        newData.objectIndex  = this.objectIndex; 
        newData.geomSurfaceIndex  = this.geomSurfaceIndex; 
        newData.geomCurveIndex  = this.geomCurveIndex; 
        newData.geomPointIndex  = this.geomPointIndex; 
        newData.freePoint.Clone(this.freePoint); 
   
        return newData;
    }

    this.Copy = function (data) {
        this.elementType  = data.elementType; 
        this.objectIndex  = data.objectIndex; 
        this.geomSurfaceIndex  = data.geomSurfaceIndex; 
        this.geomCurveIndex  = data.geomCurveIndex; 
        this.geomPointIndex  = data.geomPointIndex; 
        this.freePoint.Clone(data.freePoint); 
    }
}

// 测量信息
function P3D_MEASUREMARK() {
    this.baseInfo = new P3D_BASEMARK();			    // 基础信息
    this.measureType = P3D_MEASURE_NONE;            // 测量类型，参考P3D_MEASURE_***定义
    this.result = new P3D_TEXTNOTEMARK();			// 测量结果

    this.Clone = function () {
        var newData = new P3D_MEASUREMARK();
        newData.baseInfo.Copy(this.baseInfo); 
        
        newData.measureType  = this.measureType; 
        newData.result.Clone(this.result);        

        return newData;
    }

    this.Copy = function (data) {
        this.baseInfo.Copy(data.baseInfo); 

        this.measureType  = data.measureType; 
        this.result.Clone(data.result); 
    }
}

// 视图类型
const P3DVIEWTTYPE_STAND				= 1;				// 标准视图
const P3DVIEWTTYPE_PMI					= 2;				// PMI视图
const P3DVIEWTTYPE_CUSTOM				= 3;				// 自定义视图

// 视图的材质ID
function P3D_VIEWMATERIALINFO() {
	this.objID = -1;										// 模型实例ID
    this.arrSubsetIndex = new Array();                      // 模型实例的面序号数组
	this.materialID = -1;									// 材质ID

    this.Clone = function () {
        var newData = new P3D_VIEWMATERIALINFO();
         
        newData.objID  = this.objID; 
    
        for (var i in this.arrSubsetIndex){
            newData.arrSubsetIndex[i] = this.arrSubsetIndex[i];
        }
        newData.materialID  = this.materialID;        
 
        return newData;
    }

    this.Copy = function (data) {
        this.objID  = data.objID; 

        this.arrSubsetIndex.splice(0, this.arrSubsetIndex.length);
        for (var i in data.arrSubsetIndex){
            this.arrSubsetIndex[i].Copy(data.arrSubsetIndex[i]);
        } 

        this.materialID  = data.materialID; 
     }
}
 
// 模型的位置信息
function P3D_VIEW_OBJPOS() {
    this.objID  = -1;							    // 模型实例ID
	this.matWorld = new P3D_BASEMATRIX();			// 模型实例世界变化矩阵
}

// 视图数据
function P3D_VIEWINFO() {
	this.ID = -1;									// 视图ID
	this.strName = "";							    // 视图名称
	this.type = P3DVIEWTTYPE_CUSTOM;				// 视图类型，参考3DVIEWTTYPE定义
	this.value = 0;								    // type为标准视图时，取值如下：	1：正视图 2：后视图	3：左视图 4：右视图	5：俯视图 6：仰视图 7：等轴侧
													// type为PMI视图时，取值为PMI视图ID
													// type为自定义视图时，无效，使用_viewCamera数据切换视角
    this.viewCamera = new P3D_CAMERA();				// 摄像机数据,P3D_CAMERA

	this.bkType = 0;								// 视图背景类型：0没有背景设置,	1设置背景色, 2设置背景图片
	this.bkColor = new P3D_RGBA();					// 背景颜色, 
	this.projectionType = 0;						// 投影类型, 0: 表示透视投影 1: 表示正交投影
    
	this.renderMode = P3D_RENDER_MODE_SHADER;		// 渲染模式, 参考P3D_RENDER_MODE枚举值
    this.arrMaterialData = new Array();             // 材质数据数组,存储P3D_VIEWMATERIALINFO数据

	this.visbleObjFlag = 1;						    // 1表示_vecObjIDc存储显示的obj对象，0表示_vecObjIDc存储隐藏的obj对象
    this.arrObjID = new Array();                    // 模型实例数组
		
    this._vecObjPos = new Array();                  // 模型的位置信息,存储P3D_VIEW_OBJPOS数据

    this.arrSectionPlane = new Array();             // 剖切面数组,存储 P3D_SECTION_PLANE_INFO 数据
}

// 分解视图模型实例节点
function P3D_EXPLODEDOBJNODE() {
	this.strName = "";						        // 节点名称
	this.ID = -1;								    // 节点ID
	this.objID= -1;							        // 模型实例ID

    this.arrExplodedPoint = new Array();            // 分解点, 存储P3DMARK_POINTSPACE数据
    this.noteText = new P3D_TEXTNOTEMARK();			// 球标文字
  
    this.matWorld = new P3D_BASEMATRIX();			// 模型实例世界变化矩阵
    this.visible = 1;						        // 1表示节点可见，0表示节不点可见

    this.Clone = function () {
        var newData = new P3D_EXPLODEDOBJNODE();
         
        newData.strName  = this.strName; 
        newData.ID  = this.ID; 
        newData.objID  = this.objID; 
    
        for (var i in this.arrExplodedPoint){
            newData.arrExplodedPoint[i].Copy(this.arrExplodedPoint[i]);
        }
        newData.noteText.Copy(this.noteText);     

        newData.matWorld.Copy(this.matWorld);   
        newData.visible  = this.visible;   
 
        return newData;
    }

    this.Copy = function (data) {
        this.strName  = data.strName; 
        this.ID  = data.ID; 
        this.objID  = data.objID; 

        this.arrExplodedPoint.splice(0, this.arrExplodedPoint.length);
        for (var i in data.arrExplodedPoint){
            this.arrExplodedPoint[i].Copy(data.arrExplodedPoint[i]);
        } 

        this.noteText.Copy(data.noteText);  

        this.matWorld.Copy(data.matWorld);  
        this.visible  = data.visible; 
     }
}

// 分解视图组节点
function P3D_EXPLODEDGROUPNODE() {
    this.strName = "";						        // 节点名称
	this.ID = -1;								    // 节点ID

    this.arrExplodedPoint = new Array();            // 分解点, 存储P3DMARK_POINTSPACE数据
    this.arrObjNode = new Array();				    // 模型实例节点, 存储P3D_EXPLODEDOBJNODE数据
    this.noteText = new P3D_TEXTNOTEMARK();			// 球标文字

    this.box = new P3D_BOX();				        // 包围盒

    this.Clone = function () {
        var newData = new P3D_EXPLODEDGROUPNODE();
         
        newData.strName  = this.strName; 
        newData.ID  = this.ID; 
    
        for (var i in this.arrExplodedPoint){
            newData.arrExplodedPoint[i].Copy(this.arrExplodedPoint[i]);
        }
           
        for (var i in this.arrObjNode){
            newData.arrObjNode[i].Copy(this.arrObjNode[i]);
        }

        newData.noteText.Copy(this.noteText);  
        newData.box._max.Copy(this.box._max);   
        newData.box._min.Copy(this.box._min);   
 
        return newData;
    }

    this.Copy = function (data) {
        this.strName  = data.strName; 
        this.ID  = data.ID; 

        this.arrExplodedPoint.splice(0, this.arrExplodedPoint.length);
        for (var i in data.arrExplodedPoint){
            this.arrExplodedPoint[i].Copy(data.arrExplodedPoint[i]);
        } 

        this.arrObjNode.splice(0, this.arrObjNode.length);
        for (var i in data.arrObjNode){
            this.arrObjNode[i].Copy(data.arrObjNode[i]);
        } 

        this.noteText.Copy(data.noteText); 
        this.box._max.Copy(data.box._max);   
        this.box._min.Copy(data.box._min); 
     }
}

// 分解视图的物料清单表头信息
function P3D_EXPLODEDVIEWBOMHEADER() {
    this.strTitle = "";						        // Bom的标题名
    this.strKey = "";						        // 模型实例的Key值

    this.Clone = function () {
        var newData = new P3D_EXPLODEDVIEWBOMHEADER();
         
        newData.strTitle  = this.strTitle; 
        newData.strKey  = this.strKey; 
    }

    this.Copy = function (data) {
        this.strTitle  = data.strTitle; 
        this.strKey  = data.strKey; 
    }
}

// 物料清单中模型实例交互标记
const P3D_EXPLOADEDINTERFLAG_NULL = 0;					// 无
const P3D_EXPLOADEDINTERFLAG_SEL = 1;					// 选中
const P3D_EXPLOADEDINTERFLAG_SELANDFOCUS = 2;			// 特写（选中并聚焦）
const P3D_EXPLOADEDINTERFLAG_ENHANCED = 3;				// 凸显
const P3D_EXPLOADEDINTERFLAG_ENHANCEDANDFOCUS = 4;		// 凸显并聚焦
const P3D_EXPLOADEDINTERFLAG_FLICKER = 5;				// 闪烁

// 分解视图
function P3D_EXPLODEDVIEW() {
    this.strName = "";						            // 节点名称
	this.ID = -1;								        // 节点ID
    this.camera = new P3D_CAMERA();				        // 摄像机数据,P3D_CAMERA

    this.arrObjNode = new Array();				        // 模型实例节点, 存储P3D_EXPLODEDOBJNODE数据
    this.arrObjGroupNode = new Array();                 // 分解视图组节点, 存储P3D_EXPLODEDGROUPNODE数据

    this.projectType = P3D_EXPLOADEDINTERFLAG_ENHANCED;	// 摄像机投影类型

    this._arrCenterLine = new Array();			        // 中心线数组,存储P3D_LINEMARK数据

    this.Clone = function () {
        var newData = new P3D_EXPLODEDGROUPNODE();
         
        newData.strName  = this.strName; 
        newData.ID  = this.ID; 
    
        newData.camera.Copy(this.camera);   

        for (var i in this.arrObjNode){
            newData.arrObjNode[i].Copy(this.arrObjNode[i]);
        }
           
        for (var i in this.arrObjGroupNode){
            newData.arrObjGroupNode[i].Copy(this.arrObjGroupNode[i]);
        }

        newData.projectType  = this.projectType; 

        for (var i in this._arrCenterLine){
            newData._arrCenterLine[i].Copy(this._arrCenterLine[i]);
        }

        return newData;
    }

    this.Copy = function (data) {
        this.strName  = data.strName; 
        this.ID  = data.ID; 

        this.arrObjNode.splice(0, this.arrObjNode.length);
        for (var i in data.arrObjNode){
            this.arrObjNode[i].Copy(data.arrObjNode[i]);
        } 

        this.arrObjGroupNode.splice(0, this.arrObjGroupNode.length);
        for (var i in data.arrObjGroupNode){
            this.arrObjGroupNode[i].Copy(data.arrObjGroupNode[i]);
        } 
       
        this.projectType  = data.projectType; 

        this._arrCenterLine.splice(0, this._arrCenterLine.length);
        for (var i in data._arrCenterLine){
            this._arrCenterLine[i].Copy(data._arrCenterLine[i]);
        } 
     }
}

//===================================================================================================

// P3DToolkit库是否已经加载完毕
let isLoadedLib = false;
var g_BasisModule = false;

let p3ddocjs = document.scripts;
let p3dCurrentPath = p3ddocjs[p3ddocjs.length-1].src;
let p3dPosition = p3dCurrentPath.lastIndexOf("P3DToolkit");
var P3DTOOLKIT_ROOT_PATH = p3dCurrentPath.substring(0, p3dPosition);

// 动态加载P3DToolkit依赖库，解决不同 vue 版本兼容的问题
function loadP3DToolkitLib (cb) {    
    // P3DToolkit库依赖列表，并按顺序加载
    const P3D_LIB_DEPENDENCY_LIST = [
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'UI/static/runtime-main.min.js'},
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'UI/static/ui.min.js'},
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'UI/static/main.min.js'},   
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'p3dKernel/p3dKerenl1.js'},  
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'p3dKernel/p3dKerenl2.js'},  
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'p3dKernel/P3DTranscoder.js' },   
        
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'p3dKernel/Mark/vue.min.js' },
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'p3dKernel/Mark/p3dmark.umd.min.js' },
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'UI/comment/P3Dvendor.js'},
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'UI/comment/app.js'},
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'p3dKernel/Mark/utils.js' },
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'p3dKernel/Mark/module.js' },
        { type: 'text/javascript', src: P3DTOOLKIT_ROOT_PATH + 'p3dKernel/Mark/dialog.js' },
    ]     
   
    // 库已经加载过了，无需再次加载，直接返回
    if (isLoadedLib) {
        cb && cb(false, '');
        return;
    };

    const loadList = P3D_LIB_DEPENDENCY_LIST.map(function(item) { return item; });
    const total = loadList.length;
    let count = 0;

    function load () {
        // 加载完毕
        if (count === total) {
            isLoadedLib = true;
            cb && cb(false, '');
            return;
        }

        // 按顺序取出依赖
        const dependency = loadList.shift();
        // 创建 script 标签，加载依赖
        const script = document.createElement('script');
        script.type = dependency.type;
        script.src = dependency.src;
        // 加载完成事件
        script.onload = function() {
            count++;
            load();
        }
        // 加载失败事件
        script.onerror = function() {
            cb && cb(true, dependency.src);
        }
        document.body.appendChild(script);
    }

    load();
}